package com.t235.gc.order.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.t235.gc.AjaxResult;
import com.t235.gc.entity.HomeRecyclingOrder;
import com.t235.gc.order.service.HomeRecyclingDetailOrderService;
import com.t235.gc.order.service.HomeRecyclingOrderService;
import com.t235.gc.vo.HomeRecyclingOrderVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api
@RestController
@RequestMapping("/api/home-recycling-order")
public class HomeRecyclingOrderController {
    @Autowired
    private HomeRecyclingOrderService homeRecyclingOrderService;
    @Autowired
    private HomeRecyclingDetailOrderService homeRecyclingDetailOrderService;

    /**
     * 上门回收订单
     * @param vo
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/admin/getHomeRecyclingOrderList")
    public AjaxResult getHomeRecyclingOrderList(HomeRecyclingOrderVo vo, @RequestParam(value="page") Integer page, @RequestParam(value="limit") Integer pageSize){
        PageHelper.startPage(page,pageSize);
        List<HomeRecyclingOrder> list=homeRecyclingOrderService.getList(vo);
        PageInfo<HomeRecyclingOrder> pageInfo=new PageInfo<>(list);
        return AjaxResult.success(pageInfo);
    }

    @GetMapping("/admin/delHomeRecyclingOrder")
    public AjaxResult del(String orderid){
        if(homeRecyclingOrderService.del(orderid)>0){
            return AjaxResult.success();
        }
        return AjaxResult.error();
    }
}
